home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_jade.idb / usr / freeware / include / sp / lib / TrieBuilder.h.z / TrieBuilder.h
C/C++ Source or Header  |  1999-07-21  |  2KB  |  71 lines

  1. // Copyright (c) 1994 James Clark
  2. // See the file COPYING for copying permission.
  3.  
  4. #ifndef TrieBuilder_INCLUDED
  5. #define TrieBuilder_INCLUDED 1
  6. #ifdef __GNUG__
  7. #pragma interface
  8. #endif
  9.  
  10. #include "types.h"
  11. #include "StringOf.h"
  12. #include "Owner.h"
  13. #include "Trie.h"
  14. #include "Vector.h"
  15.  
  16. #ifdef SP_NAMESPACE
  17. namespace SP_NAMESPACE {
  18. #endif
  19.  
  20. class TrieBuilder {
  21. public:
  22.   typedef Vector<Token> TokenVector;
  23.   TrieBuilder(int nCodes);
  24.   void recognize(const String<EquivCode> &chars,
  25.          Token t,
  26.          Priority::Type pri,
  27.          TokenVector &ambiguities);
  28.   void recognize(const String<EquivCode> &chars,
  29.          const String<EquivCode> &set,
  30.          Token t,
  31.          Priority::Type pri,
  32.          TokenVector &ambiguities);
  33.   // recognize a delimiter with a blank sequence
  34.   void recognizeB(const String<EquivCode> &chars,
  35.           int bSequenceLength, // >= 1
  36.           size_t maxBlankSequenceLength,
  37.           const String<EquivCode> &blankCodes,
  38.           const String<EquivCode> &chars2,
  39.           Token t,
  40.           TokenVector &ambiguities);
  41.   void recognizeEE(EquivCode code, Token t);
  42.   Trie *extractTrie() { return root_.extract(); }
  43. private:
  44.   TrieBuilder(const TrieBuilder &); // undefined
  45.   void operator=(const TrieBuilder &); // undefined
  46.   void doB(Trie *trie,
  47.        int tokenLength,
  48.        int minBLength,
  49.        size_t maxLength,
  50.        const String<EquivCode> &blankCodes,
  51.        const String<EquivCode> &chars2,
  52.        Token token,
  53.        Priority::Type pri,
  54.        TokenVector &ambiguities);
  55.   Trie *extendTrie(Trie *, const String<EquivCode> &);
  56.   void setToken(Trie *trie, int tokenLength, Token token, Priority::Type pri,
  57.         TokenVector &ambiguities);
  58.  
  59.   Trie *forceNext(Trie *trie, EquivCode);
  60.   void copyInto(Trie *, const Trie *, int);
  61.  
  62.   int nCodes_;
  63.   Owner<Trie> root_;
  64. };
  65.  
  66. #ifdef SP_NAMESPACE
  67. }
  68. #endif
  69.  
  70. #endif /* not TrieBuilder_INCLUDED */
  71.